@extends('layouts.app')
@include('user.sidebar')
@section('content')
    <div class="content">
        <div class="row custom-invoice">
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>用户昵称</th>
                    <th>用户头像</th>
                    <th>姓名</th>
                    <th>身份证号</th>
                    <th>地址</th>
                    <th>公司</th>
                    <th>职业</th>
                    <th>形象照</th>
                    <th>证件照</th>
                    <th>店员</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $item)
                    <tr>
                        <td>{{ $item->nickname }}</td>
                        <td>
                            <img src="{{ $item->avatar }}" width="30">
                        </td>
                        <td>{{ $item->name }}</td>
                        <td>{{ $item->id_number }}</td>
                        <td>{{ $item->address }}</td>
                        <td>{{ $item->company }}</td>
                        <td>{{ $item->job }}</td>
                        <td>
                            <a class="btn btn-info btn-xs show-image" data-image="{{ $item->image }}">查看</a>
                        </td>
                        <td>
                            <a class="btn btn-info btn-xs show-image" data-image="{{ $item->id_card }}">查看</a>
                        </td>
                        <td>{{ $item->personal }}</td>
                        <td>{{ \App\Modules\User\Models\ApplyPartner::$statusShow[$item->status] }}</td>
                        <td>
                            @can('user-apply-edit')
                            <a class="btn btn-info btn-xs" href="{{ route('admin.user.partner.edit', ['id' => $item->id, 'upstream' => 'list']) }}"><i class="fa fa-edit"></i> 修改</a>
                            @if ($item->status == \App\Modules\User\Models\ApplyPartner::STATUS_INIT)
                                <a class="btn btn-primary btn-xs" href="{{ route('admin.user.partner.pass', ['id' => $item->id]) }}"><i class="fa fa-check"></i> 通过</a>
                                <a class="btn btn-primary btn-xs check-fail"  data-url="{{ route('admin.user.partner.refuse', ['id' => $item->id]) }}"><i class="fa fa-hand-paper-o"></i> 拒绝</a>
                            @endif
                            @endcan
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            {{ $data->links() }}
        </div>

        <div class="modal fade loading custom-hide"  style="width: 100%;text-align: center" id="hideForm" tabindex="-1" role="dialog" aria-labelledby="hideFormLibel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
            <div class="modal-dialog" style="width: 1000px">
                <div  class="content invoice" style="position: relative; margin: auto">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> 关闭 </button>
                    </div>
{{--                    <span id="closeHideForm" class="span-X"><i class="fa fa-close"></i></span>--}}
                    <div class="row" id = "image-content">
                    </div>
                </div>
            </div>
        </div>

        <div class="modal fade" id="fail-modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div  class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    </div>
                    <div class="modal-body">
                        <form class="form" method="post" action="" id="reason-form">
                            <input type="hidden" name="_token" value="{{ csrf_token() }}" />
                            <div class="form-group">
                                <label for="reason">理由：</label>
                                <input class="form-control" type="text" name="reason" id="reason" required>
                            </div>
                            <button type="submit" class="btn btn-success form-control">提交</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@push('stylesheets')
    <style>
        .span-X {
            position: absolute;
            border-radius: 50px;
            top: 10px;
            right: 10px;
            padding: 3px 5px;
            line-height: 0;
            background-color: rgba(190,190,190,0.50);
        }
    </style>
@endpush
@push('scripts')
    <script>
        $('.show-image').on('click', function () {
            var k = $(this).attr('data-image').split(";");
            node = "";
            for(index in k) {
                node += "<div style= \"float:left;margin: 10px;\">\n" +
                    "       <img src=\"" + k[index] + "\" width='100%'>\n" +
                    "   </div>";
            }
            $('#image-content').html(node);
            $("#hideForm").modal('show');
        });
        $('#closeHideForm').on('click', function () {
            $("#hideForm").modal('hide');
        });

        $('.check-fail').on('click', function () {
            var url = $(this).attr('data-url');
            $('#reason-form').attr('action', url);
            $("#fail-modal").modal('show');
        });
    </script>
@endpush
